package com.mi2021;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Set;

public class Main1 {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] passwords = br.readLine().split(" ");
        for (int i = 0; i < passwords.length; i++) {
            int res = checkPassword(passwords[i]);
            System.out.println(res);
        }
    }

    private static int checkPassword(String password) {

        int len = password.length();
        if(len < 8 || len > 120){
            return 1;
        }
        Set<Integer> type = new HashSet<>();
        for (int i = 0; i < len; i++) {
            char t = password.charAt(i);
            if(t >= '0' && t <= '9'){
                type.add(1);
            }else if(t >= 'a' && t <= 'z'){
                type.add(2);
            }else if(t >= 'A' && t <= 'Z'){
                type.add(3);
            }else{
                type.add(4);
            }
        }
        if(type.size() < 4){
            return 2;
        }
        return 0;

    }


}
